<?php
namespace app\controllers;

use app\models\Goods;
use Yii;
use yii\web\Controller;
use app\models\UploadForm;
use yii\web\UploadedFile;

class GoodsController extends Controller
{
    public function actionUpload()
    {
        $model = new UploadForm();

        if (Yii::$app->request->isPost) {
            $model->imageFile = UploadedFile::getInstance($model, 'imageFile');
            if ($model->upload()) {
                // 文件上传成功
                return;
            }

        }

        return $this->render('upload', ['model' => $model]);
    }

    public function actionGoodsshow(){
        //实例化
        $model=new Goods();
        //验证判断
        if(!$model->validate()){
            echo "验证失败";
            die();
        }

        $res=$model->selectAll();
        if($res){
           return $this->render("show",['data'=>$res]);
        }else{
           echo "查询失败";
            die();
        }


    }
}

?>
